<?php if(!empty($subvo)){
    $v = $subvo;
    $subvo = '';
}
if(!empty($subsubvo)){
    $v = $subsubvo;
    $subsubvo = '';
}
?>





<div class="viewBox myBox<?php echo $v['id'];?>" <?php if($_SESSION[C('USER_AUTH_KEY')]){?> sortID="<?php echo $v['sort'];?>" modulesID="<?php echo $v['id'];?>" title="<?php echo $v['title'];?>" deleteUrl="<?php echo U('/Admin/Modules/delete',array('id'=>$v['id']));?>" settingUrl="<?php echo U('/Admin/Modules/edit',array('id'=>$v['id']));?>" isEdit="0"<?php }?>>
  <?php if(!empty($v['dataname'])){
                $v['content'] = $v['dataname'];
                
        }
         ?>
         <div class="panel panel-primary">
    <?php include(TMPL_PATH.'Home/TemplateDefault/Public-Moduletitle'.C('TMPL_TEMPLATE_SUFFIX')); ?>
<div class="panel-body">
















<?php if(empty($productList)){?> 

<!-- 没有商品 -->
    
        <div style="text-align:center;"><i class="fa fa-shopping-cart" style="font-size:150px; color:#D0D0D0;"></i><p>购车中没有商品！</p><p>&nbsp;</p>
        <div class="row">
            
            <div class="col-xs-6 col-sm-6"><a style="display:block; margin:10px;" href="__APP__/" class="btn btn-warning btn-lg"><i class="fa fa-home"></i> 去购物</a></div>
            <div class="col-xs-6 col-sm-6"><a style="display:block; margin:10px;" href="<?php echo U('Member/Index/index');?>" class="btn btn-default btn-lg"><i class="fa fa-user"></i> 会员中心</a></div>
        </div></div>
    
      
    <!-- --> 



<?php }else{?>









<div class="mains">
  <div class="panel panel-info" style=" margin: 5px 5px 0px 5px ;">
    <div class="panel-heading"><i class="glyphicon glyphicon-shopping-cart"></i> 我的购物车</div>
    <?php $mykey = 0; foreach($productList as $key => $vo){?>
    <?php if($mykey > 0){?>
    <div class="line_" style="height:1px; margin:0 5px; background:#ddd;"></div>
    <?php }?>
    <div class="media" style="position:relative;" id="cart_<?php echo $vo['id'];?>">
      <div class="media-left"> <a href="##" style="width:80px; height:80px; display:block;"> <img width="80" height="80" class="media-object" src="<?php echo getThumbPath($vo['img_url']);?>" data-holder-rendered="true" style="width: 80px; height: 80px;"> </a> </div>
      <div class="media-body">
        <h4 class="media-heading"><?php echo $vo['title'];?></h4>
        <p>
          <?php if(!empty($vo['attrmes'][0])){?>
          <span style="color:rgba(203,189,190,1.00)">规格:&nbsp;&nbsp;</span>
          <?php foreach($vo['attrmes'] as $vos){?>
          <span><?php echo $vos ?>&nbsp;&nbsp;</span>
          <?php }?>
          <?php }?>
        </p>
        <div class="row" style="line-height:30px;">
          <div class="col-xs-6">
            <div class="input-group input-group-sm"> <span class="input-group-btn">
              <button class="btn btn-default sub_" type="button">-</button>
              </span>
              <input class="form-control cartNum" style="text-align:center;" goods_idmd5="<?php echo md5($cartdata[$key][0]);?>" goods_id="<?php echo $cartdata[$key][0];?>" goods_title="<?php echo $cartdata[$key][1];?>" goods_price="<?php echo $cartdata[$key][3];?>" goods_attr="<?php echo $cartdata[$key][4];?>" type="text" name="" value="<?php echo $vo['num'];?>">
              <span class="input-group-btn">
              <button class="btn btn-default add_" type="button">+</button>
              </span> </div>
          </div>
          <div class="col-xs-6">&times;&nbsp;<span style="color:#f00;">¥<span id="ajaxprice<?php echo md5($cartdata[$key][0]);?>"><?php echo $vo['price'];?></span></span></div>
        </div>
      </div>
      <a href="javascript:void(0);" style="position:absolute; bottom:5px; font-size:1.5em; right:10px;" onClick="deletecart('<?php echo $cartdata[$key][0];?>',this);"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a> </div>
    <?php $mykey++; }?>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
  </div>
  <div style="height:50px;"></div>
  <div id="bootomNav" style="background:rgba(219,214,214,1); z-index:10000; height:50px; line-height:50px; left:0;">
    <div class="row">
      <div class="col-sm-7 col-xs-7" style="text-align:left; padding:0; padding-left:8px; line-height:50px;">合计：<span style="color:red; font-size:1.2em;">¥<span id="_total"><?php echo $total;?></span></span></div>
      <div class="col-xs-5 col-sm-5" style="padding:0;"><a href="{:U('checkOut')}" class="btn-danger" style="display:block; font-size:1.3em; text-align:center" ><i class="glyphicon glyphicon-arrow-right"></i> 去结算</a></div>
    </div>
  </div>
</div>
<?php }?>


<?php if(strtolower(GROUP_NAME) != 'admin'){?>
<script>



function deletecart(id,e){
    if(!confirm('您确定要删除吗？')){
		return false;
	}
	$.post('<?php echo U('Cart/delete');?>',{'id':id,'cart':1},function(data){
		if(data.status == 1){
			$(e).parent().prev('.line_').remove();
			$(e).parent().remove();
			if($('.mains .media').length == 0){
				location.reload();
			}
			$('#_total').html(data.total);
		}
	},'json');
}


//更新购物车
$('.add_').click(function(e) {
	var val = $(this).parent().prev('input').eq(0).val()*1;
	$(this).parent().prev('input').eq(0).val(val + 1);
	changeNum($(this).parent().prev('input').eq(0));
});
$('.sub_').click(function(e) {
    var val = $(this).parent().next('input').eq(0).val()*1;
	if(val > 1){
		$(this).parent().next('input').eq(0).val(val - 1);
	}
    changeNum($(this).parent().next('input').eq(0));
});


function changeNum(e){
	$.ajax({
			url:'<?php echo U('Cart/update');?>',
			data:"id="+$(e).attr('goods_id')+"&title="+$(e).attr('goods_title')+"&price="+$(e).attr('goods_price')+"&total="+$(e).val()+"&attr="+$(e).attr('goods_attr')+'&cart=1',
			type:'POST',
			dataType:"html",
			success: function(data){
				
				$.ajax({
					url:'<?php echo U('Cart/getPriceByOne');?>',
					data:"id="+$(e).attr('goods_id'),
					type:'POST',
					dataType:"html",
					success: function(data){
						if(data != ''){
							$('#ajaxprice'+$(e).attr('goods_idmd5')).html(data);
						}
					}
				});
				
				
				if(data != ''){
				    $('#_total').html(data);
				}
			}
		});
}



//更新购物车
$(".cartNum").each(function(index, element) {
	$(this).change(function(e) {
		if($(this).val() < 1){
		$(this).val(1);
	}
        
		
		
		changeNum(element);
		
    });
    
});



</script> 
<?php }?>



</div>
</div></div>